public class sxh {


    public static void main(String[] args) {

        //n = 167 (假定一个值)


        for (int i = 0; i < 999999; i++) { //求0到999999之间的自幂数
            int count = 0;
            int tmp = i;
            while(tmp != 0){  //对整形下的数进行判断位数
                tmp /= 10;
                count++;
            }
            tmp = i;
            int sum = 0;
            while(tmp != 0) {
                sum += Math.pow(tmp % 10, count); //Math.pow()将count作为该余数的指数
                tmp /= 10;
            }
            if (sum == i)
                System.out.println(i);
        }

    }


}